Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use latest flashlight code that initializes domain fronting quicker #1257

Merged
merged 12 commits into from
Dec 12, 2024

Conversation

myleshorton
Copy link
Contributor

@myleshorton myleshorton commented Dec 9, 2024

This just uses the latest flashlight code that speeds up the selection of working domain fronts on startup, which also speeds up connecting to proxies.

Copy link
Contributor

@atavism atavism left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I haven't tested iOS, but it's working well for me on macOS

@atavism atavism requested a review from jigar-f December 10, 2024 03:29
@jigar-f
Copy link
Contributor

jigar-f commented Dec 10, 2024

In Android it crashes with these logs, That is the same as before that I got while using the new fronted.

System language code: en_IN
13:20:56.983  E  runtime: newstack at runtime.printlock+0x78 sp=0x400007c9b0 stack=[0x400007c000, 0x400007d000]
13:20:56.983  E  	morebuf={pc:0x78b3342780 sp:0x400007c9b0 lr:0x0}
13:20:56.983  E  	sched={pc:0x78b337a808 sp:0x400007c9b0 lr:0x78b3342780 ctxt:0x0}
13:20:56.983  E  runtime.callbackUpdateSystemStack(0x400006e008, 0x7ff24db6d0, 0x0)
13:20:56.983  E  	/usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x400007ca10 sp=0x400007c9b0 pc=0x78b3342780
13:20:56.983  E  runtime.cgocallbackg(0x78b4372b10, 0x7ff24db7c0, 0x0)
13:20:56.983  E  	/usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x400007ca90 sp=0x400007ca10 pc=0x78b3342948
13:20:56.983  E  runtime.cgocallbackg(0x78b4372b10, 0x7ff24db7c0, 0x0)
13:20:56.983  E  	<autogenerated>:1 +0x1c fp=0x400007cac0 sp=0x400007ca90 pc=0x78b33b7f5c
13:20:56.983  E  runtime.cgocallback(0x400007cb38, 0x78b4345c64, 0x78b437ebf0)
13:20:56.983  E  	/usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x400007caf0 sp=0x400007cac0 pc=0x78b33b5dd0
13:20:56.983  E  runtime.systemstack_switch()
13:20:56.983  E  	/usr/local/go/src/runtime/asm_arm64.s:200 +0x8 fp=0x400007cb00 sp=0x400007caf0 pc=0x78b33b3998
13:20:56.983  E  runtime.cgocall(0x78b437ebf0, 0x400007cb78)
13:20:56.983  E  	/usr/local/go/src/runtime/cgocall.go:175 +0x70 fp=0x400007cb40 sp=0x400007cb00 pc=0x78b3342690
13:20:56.983  E  main._Cfunc_cproxyminisql_DB_Exec(0x2a, {0x7a2a44f750, 0xc8, {0x0, 0x0, 0x0, 0x0}}, 0xffffffe7)
13:20:56.983  E  	_cgo_gotypes.go:1649 +0x34 fp=0x400007cb70 sp=0x400007cb40 pc=0x78b4345c64
13:20:56.983  E  main.(*proxyminisql_DB).Exec.func1(0x40006283a4, {0x7a2a44f750, 0xc8, {0x0, 0x0, 0x0, 0x0}}, 0xffffffe7)
13:20:56.983  E  	/private/var/folders/v0/7k3mc29n0g3g_t5kw4fpp0yc0000gn/T/gomobile-work-2857396071/src-android-arm64/gobind/go_minisqlmain.go:584 +0x84 fp=0x400007cbd0 sp=0x400007cb70 pc=0x78b435df14
13:20:56.983  E  main.(*proxyminisql_DB).Exec(0x40006283a4, {0x4000596070?, 0x10?}, {0x78b4946d68, 0x400000e2e8})
13:20:56.983  E  	/private/var/folders/v0/7k3mc29n0g3g_t5kw4fpp0yc0000gn/T/gomobile-work-2857396071/src-android-arm64/gobind/go_minisqlmain.go:584 +0x7c fp=0x400007cc20 sp=0x400007cbd0 pc=0x78b435dd8c
13:20:56.983  E  github.com/getlantern/pathdb/minisql.(*QueryableAPI).Exec(0x4000590070, {0x4000596070, 0x64}, {0x0?, 0x1?, 0x78b335897c?})
13:20:56.983  E  	/Users/jigarfumakiya/go/pkg/mod/github.com/getlantern/[email protected]/minisql/api.go:14 +0x6c fp=0x400007cc60 sp=0x400007cc20 pc=0x78b4151bac
13:20:56.983  E  github.com/getlantern/pathdb.NewDB({0x78b494f668, 0x40006283a4}, {0x78b2fa4bc5, 0x3})
13:20:56.983  E  	/Users/jigarfumakiya/go/pkg/mod/github.com/getlantern/[email protected]/db.go:125 +0x14c fp=0x400007cd40 sp=0x400007cc60 pc=0x78b41566cc
13:20:56.984  E  github.com/getlantern/lantern-client/internalsdk.newModel({0x78b2fa4bc5, 0x3}, {0x78b494f668?, 0x40006283a4?})
13:20:56.984  E  	/Users/jigarfumakiya/Documents/getlantern/mobile_app/lantern-client/internalsdk/model.go:87 +0x44 fp=0x400007cd80 sp=0x400007cd40 pc=0x78b43171e4
13:20:56.984  E  github.com/getlantern/lantern-client/internalsdk.NewVPNModel({0x78b494f668?, 0x40006283a4?})
13:20:56.984  E  	/Users/jigarfumakiya/Documents/getlantern/mobile_app/lantern-client/internalsdk/vpn_model.go:27 +0x38 fp=0x400007cdc0 sp=0x400007cd80 pc=0x78b4331a88
13:20:56.984  E  main.proxyinternalsdk__NewVPNModel(0x2a)
13:20:56.984  E  	/private/var/folders/v0/7k3mc29n0g3g_t5kw4fpp0yc0000gn/T/gomobile-work-2857396071/src-android-arm64/gobind/go_internalsdkmain.go:4720 +0x64 fp=0x400007ce10 sp=0x400007cdc0 pc=0x78b435b564
13:20:56.984  E  _cgoexp_44039f0b4376_proxyinternalsdk__NewVPNModel(0x7ff24dd010)
13:20:56.984  E  	_cgo_gotypes.go:5222 +0x28 fp=0x400007ce30 sp=0x400007ce10 pc=0x78b4371378
13:20:56.984  E  runtime.cgocallbackg1(0x78b4371350, 0x7ff24dd010, 0x0)
13:20:56.984  E  	/usr/local/go/src/runtime/cgocall.go:420 +0x228 fp=0x400007cf00 sp=0x400007ce30 pc=0x78b3342cc8
13:20:56.984  E  runtime.cgocallbackg(0x78b4371350, 0x7ff24dd010, 0x0)
13:20:56.984  E  	/usr/local/go/src/runtime/cgocall.go:339 +0x10c fp=0x400007cf80 sp=0x400007cf00 pc=0x78b33429ec
13:20:56.984  E  runtime: newstack at runtime.printlock+0x78 sp=0x400007c9b0 stack=[0x400007c000, 0x400007d000]
13:20:56.984  E  runtime.cgocallbackg(0x78b4371350, 0x7ff24dd010, 0x0)
13:20:56.984  E  	<autogenerated>:1 +0x1c fp=0x400007cfb0 sp=0x400007cf80 pc=0x78b33b7f5c
13:20:56.984  E  	morebuf={pc:0x78b3342780 sp:0x400007c9b0 lr:0x0}
13:20:56.984  E  runtime.cgocallback(0x0, 0x0, 0x0)
13:20:56.984  E  	sched={pc:0x78b337a808 sp:0x400007c9b0 lr:0x78b3342780 ctxt:0x0}
13:20:56.984  E  	/usr/local/go/src/runtime/asm_arm64.s:1130 +0xb0 fp=0x400007cfe0 sp=0x400007cfb0 pc=0x78b33b5dd0
13:20:56.984  E  runtime.goexit({})
13:20:56.984  E  runtime.callbackUpdateSystemStack(0x400006e008, 0x7ff24db6d0, 0x0)
13:20:56.984  E  	/usr/local/go/src/runtime/asm_arm64.s:1222 +0x4 fp=0x400007cfe0 sp=0x400007cfe0 pc=0x78b33b5ec4
13:20:56.984  E  fatal error: runtime: stack split at bad time
13:20:56.984  E  	/usr/local/go/src/runtime/cgocall.go:241 +0x90 fp=0x400007ca10 sp=0x400007c9b0 pc=0x78b3342780
13:20:56.984  E  runtime.cgocallbackg(0x78b4372b10, 0x7ff24db7c0, 0x0)
13:20:56.984  E  	/usr/local/go/src/runtime/cgocall.go:306 +0x68 fp=0x400007ca90 sp=0x400007ca10 pc=0x78b3342948
13:20:56.984  E  runtime.cgocallbackg(0x78b4372b10, 0x7ff24db7c0, 0x0)
13:20:56.984  E  	<autogenerated>:1 +0x1c fp=0x400007cac0 sp=0x400007ca90 pc=0x78b33b7f5c
---------------------------- PROCESS ENDED (13367) for package org.getlantern.lantern ----------------------------
---------------------------- PROCESS STARTED (13558) for package org.getlantern.lantern ----------------------------

Copy link
Contributor

@jigar-f jigar-f left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Getting crashes on Android and IOS

@myleshorton
Copy link
Contributor Author

Very interesting. Will look. Anything in particular you're doing to reproduce the crashes?

@jigar-f
Copy link
Contributor

jigar-f commented Dec 10, 2024

Create a new go lib make android ANDROID_ARCH=all and run the app

@@ -100,8 +104,11 @@ type UserConfig struct {

// TODO: Implement a timeout mechanism to handle prolonged execution times and potentially execute this method in the background to maintain smooth UI startup performance.
func (cf *configurer) Configure(userID int, proToken string, refreshProxies bool) (*ConfigResult, error) {
// Log the full method run time.
defer func(start time.Time) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@myleshorton Also Running this in IOS, It still takes around, Is this expected?
ios: config.go:109 Configured completed in 7.802894417s

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not super surprising, no. What was it taking before?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest thing is this method should definitely not block the UI thread

Copy link
Contributor

@jigar-f jigar-f Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's not super surprising, no. What was it taking before?

For me, it's the same as before,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The biggest thing is this method should definitely not block the UI thread

Yeah, We might need to make changes soon.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah in uncensored countries, there won't be much difference. We should, however, look at what is actually taking that time -- I'll eventually trace all this stuff.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1259 This should fix IOS crash and you should be able to run it and see whats going on

@jigar-f
Copy link
Contributor

jigar-f commented Dec 10, 2024

@myleshorton Can you take look at this #1259, See if that helps

@myleshorton
Copy link
Contributor Author

Curious if this works for you on iOS now @jigar-f

@jigar-f
Copy link
Contributor

jigar-f commented Dec 11, 2024

@myleshorton it Does't work it crashes because the fronter is nil on RoundTrip

@myleshorton
Copy link
Contributor Author

Huh -- you tested after my last change right? That means that, prior to any of these changes, we would call into the proxied package before we'd initialized the global config at all?

@jigar-f
Copy link
Contributor

jigar-f commented Dec 11, 2024

Yeah, I tested after your changes on adding frontend,it seems right that proxied package gets called before we fetch config. I think it might gets called from session model somewhere init method maybe.

@myleshorton
Copy link
Contributor Author

Yeah I agree -- I think session model might be the culprit.

@jigar-f
Copy link
Contributor

jigar-f commented Dec 12, 2024

@myleshorton I figured out that code takes around 99% time, of Configure Method. here only cf.updateGlobal take around 99% of time.

               log.Debug("Updating global config")
		global, globalUpdated = cf.updateGlobal(cf.rt, global, globalEtag, "https://globalconfig.flashlightproxy.com/global.yaml.gz")
		log.Debug("Updated global config")
		if refreshProxies {
			log.Debug("Refreshing proxies")
			proxies, proxiesUpdated = cf.updateProxies(proxies, proxiesEtag)
			log.Debug("Refreshed proxies")
		}

@atavism atavism mentioned this pull request Dec 12, 2024
@myleshorton myleshorton merged commit 97658b2 into main Dec 12, 2024
2 checks passed
@myleshorton myleshorton deleted the myles/early-fronting branch December 12, 2024 21:45
@myleshorton
Copy link
Contributor Author

Does this latest change work for you @jigar-f or @atavism?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants